
import javax.swing.JOptionPane;

public class Interfaz extends javax.swing.JFrame {

    int contincrementa=0;
    int contdecremento=0;
    int reset=0;
    int acumulador1=0;
    int acumulador2=0;
    String cadena="";


    public Interfaz() {
        initComponents();
    }

    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        Incrementa = new javax.swing.JButton();
        Decremento = new javax.swing.JButton();
        Reset = new javax.swing.JButton();
        Txt_Acumulador = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        Incrementa.setText("Incrementar");
        Incrementa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                IncrementaActionPerformed(evt);
            }
        });

        Decremento.setText("Decrementar");
        Decremento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                DecrementoActionPerformed(evt);
            }
        });

        Reset.setText("Reset");
        Reset.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ResetActionPerformed(evt);
            }
        });

        Txt_Acumulador.setEditable(false);
        Txt_Acumulador.setText("0");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(45, 45, 45)
                .addComponent(Incrementa)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(Txt_Acumulador, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(Decremento)
                        .addGap(18, 18, 18)
                        .addComponent(Reset)))
                .addContainerGap(23, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(61, 61, 61)
                .addComponent(Txt_Acumulador, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 150, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Reset)
                    .addComponent(Decremento)
                    .addComponent(Incrementa))
                .addGap(33, 33, 33))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void IncrementaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_IncrementaActionPerformed

             int num =0;
             num = Integer.parseInt( Txt_Acumulador.getText());
             if(num==10){
              JOptionPane.showMessageDialog(null, "Número igual a 99","Atención",JOptionPane.INFORMATION_MESSAGE);
             }
             else
             {
            num++;
            Txt_Acumulador.setText(Integer.toString(num));
             }

    }//GEN-LAST:event_IncrementaActionPerformed

    private void DecrementoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DecrementoActionPerformed
        // TODO add your handling code here:

       int num =0;
             num = Integer.parseInt( Txt_Acumulador.getText());

             if(num==0){
              JOptionPane.showMessageDialog(null, "Número igual a 0","Atención",JOptionPane.INFORMATION_MESSAGE);
             }
             else
             {
            num--;
            Txt_Acumulador.setText(Integer.toString(num));
             }
    }//GEN-LAST:event_DecrementoActionPerformed

    private void ResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ResetActionPerformed
        // TODO add your handling code here:

        Txt_Acumulador.setText(Integer.toString(0));

    }//GEN-LAST:event_ResetActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Interfaz().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Decremento;
    private javax.swing.JButton Incrementa;
    private javax.swing.JButton Reset;
    private javax.swing.JTextField Txt_Acumulador;
    // End of variables declaration//GEN-END:variables

}
